package asia.redact.bracket.security.config;

import java.io.File;
import java.io.Serializable;

/**
 * Config bean suitable for use with Spring, etc.
 * 
 * @author Dave
 * @see ZeroConfig
 */
public class BeanConfig implements SecurityConfig, Serializable {
	
	private static final long serialVersionUID = 1L;
	
	public BeanConfig() {
		super();
	
	}

	protected String keypass;
	protected String storepass;
	protected String keystoreType;
	protected String keystoreFileExtension;
	protected String signatureAlgorithm;
	protected String jCEProvider;
	protected String symmetricAlgorithm;
	protected int symmetricKeySize;
	protected int asymmetricKeySize;
	protected String asymmetricAlgorithm;
	protected boolean symmetricKeyCached;
	protected File keymaterialsBase;
	protected String subjectDN;
	protected String serialNumber;
	protected String alias;
	
	public String getKeypass() {
		return keypass;
	}
	public void setKeypass(String keypass) {
		this.keypass = keypass;
	}
	public String getStorepass() {
		return storepass;
	}
	public void setStorepass(String storepass) {
		this.storepass = storepass;
	}
	public String getKeystoreType() {
		return keystoreType;
	}
	public void setKeystoreType(String keystoreType) {
		this.keystoreType = keystoreType;
	}
	public String getKeystoreFileExtension() {
		return keystoreFileExtension;
	}
	public void setKeystoreFileExtension(String keystoreFileExtension) {
		this.keystoreFileExtension = keystoreFileExtension;
	}
	public String getSignatureAlgorithm() {
		return signatureAlgorithm;
	}
	public void setSignatureAlgorithm(String signatureAlgorithm) {
		this.signatureAlgorithm = signatureAlgorithm;
	}
	public String getJCEProvider() {
		return jCEProvider;
	}
	public void setJCEProvider(String JCEProvider) {
		this.jCEProvider = JCEProvider;
	}
	public String getSymmetricAlgorithm() {
		return symmetricAlgorithm;
	}
	public void setSymmetricAlgorithm(String symmetricAlgorithm) {
		this.symmetricAlgorithm = symmetricAlgorithm;
	}
	public int getSymmetricKeySize() {
		return symmetricKeySize;
	}
	public void setSymmetricKeySize(int symmetricKeySize) {
		this.symmetricKeySize = symmetricKeySize;
	}
	public int getAsymmetricKeySize() {
		return asymmetricKeySize;
	}
	public void setAsymmetricKeySize(int asymmetricKeySize) {
		this.asymmetricKeySize = asymmetricKeySize;
	}
	public String getAsymmetricAlgorithm() {
		return asymmetricAlgorithm;
	}
	public void setAsymmetricAlgorithm(String asymmetricAlgorithm) {
		this.asymmetricAlgorithm = asymmetricAlgorithm;
	}
	public boolean useCaching() {
		return symmetricKeyCached;
	}
	public void setSymmetricKeyCached(boolean symmetricKeyCached) {
		this.symmetricKeyCached = symmetricKeyCached;
	}
	public File getKeyMaterialsBase() {
		return keymaterialsBase;
	}
	public void setKeymaterialsBase(File keymaterialsBase) {
		this.keymaterialsBase = keymaterialsBase;
	}
	public String getSubjectDN() {
		return subjectDN;
	}
	public void setSubjectDN(String subjectDN) {
		this.subjectDN = subjectDN;
	}
	public String getSerialNumber() {
		return serialNumber;
	}
	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}
	public String getAlias() {
		return alias;
	}
	public void setAlias(String alias) {
		this.alias = alias;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((alias == null) ? 0 : alias.hashCode());
		result = prime
				* result
				+ ((asymmetricAlgorithm == null) ? 0 : asymmetricAlgorithm
						.hashCode());
		result = prime * result + asymmetricKeySize;
		result = prime * result
				+ ((jCEProvider == null) ? 0 : jCEProvider.hashCode());
		result = prime
				* result
				+ ((keymaterialsBase == null) ? 0 : keymaterialsBase.hashCode());
		result = prime * result + keypass.hashCode();
		result = prime
				* result
				+ ((keystoreFileExtension == null) ? 0 : keystoreFileExtension
						.hashCode());
		result = prime * result
				+ ((keystoreType == null) ? 0 : keystoreType.hashCode());
		result = prime * result
				+ ((serialNumber == null) ? 0 : serialNumber.hashCode());
		result = prime
				* result
				+ ((signatureAlgorithm == null) ? 0 : signatureAlgorithm
						.hashCode());
		result = prime * result + storepass.hashCode();
		result = prime * result
				+ ((subjectDN == null) ? 0 : subjectDN.hashCode());
		result = prime
				* result
				+ ((symmetricAlgorithm == null) ? 0 : symmetricAlgorithm
						.hashCode());
		result = prime * result + (symmetricKeyCached ? 1231 : 1237);
		result = prime * result + symmetricKeySize;
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BeanConfig other = (BeanConfig) obj;
		if (alias == null) {
			if (other.alias != null)
				return false;
		} else if (!alias.equals(other.alias))
			return false;
		if (asymmetricAlgorithm == null) {
			if (other.asymmetricAlgorithm != null)
				return false;
		} else if (!asymmetricAlgorithm.equals(other.asymmetricAlgorithm))
			return false;
		if (asymmetricKeySize != other.asymmetricKeySize)
			return false;
		if (jCEProvider == null) {
			if (other.jCEProvider != null)
				return false;
		} else if (!jCEProvider.equals(other.jCEProvider))
			return false;
		if (keymaterialsBase == null) {
			if (other.keymaterialsBase != null)
				return false;
		} else if (!keymaterialsBase.equals(other.keymaterialsBase))
			return false;
		if (!keypass.equals(other.keypass))
			return false;
		if (keystoreFileExtension == null) {
			if (other.keystoreFileExtension != null)
				return false;
		} else if (!keystoreFileExtension.equals(other.keystoreFileExtension))
			return false;
		if (keystoreType == null) {
			if (other.keystoreType != null)
				return false;
		} else if (!keystoreType.equals(other.keystoreType))
			return false;
		if (serialNumber == null) {
			if (other.serialNumber != null)
				return false;
		} else if (!serialNumber.equals(other.serialNumber))
			return false;
		if (signatureAlgorithm == null) {
			if (other.signatureAlgorithm != null)
				return false;
		} else if (!signatureAlgorithm.equals(other.signatureAlgorithm))
			return false;
		if (!storepass.equals(other.storepass))
			return false;
		if (subjectDN == null) {
			if (other.subjectDN != null)
				return false;
		} else if (!subjectDN.equals(other.subjectDN))
			return false;
		if (symmetricAlgorithm == null) {
			if (other.symmetricAlgorithm != null)
				return false;
		} else if (!symmetricAlgorithm.equals(other.symmetricAlgorithm))
			return false;
		if (symmetricKeyCached != other.symmetricKeyCached)
			return false;
		if (symmetricKeySize != other.symmetricKeySize)
			return false;
		return true;
	}
	
}
